package com.yanmaohu.yulia.bean;

import java.util.List;

/**
 * @author Bright Lee
 */
public final class OutputUsingClause {

    private int beginIndex;
    private int endIndex;
    private boolean sql;
    private DescriptorName descriptorName;
    private List<TargetSpecification> intoArgumentList;

    public OutputUsingClause(int beginIndex, boolean sql, DescriptorName descriptorName) {
        this.beginIndex = beginIndex;
        this.endIndex = descriptorName.getEndIndex();
        this.sql = sql;
        this.descriptorName = descriptorName;
    }

    public OutputUsingClause(int beginIndex, List<TargetSpecification> intoArgumentList ) {
        this.beginIndex = beginIndex;
        this.endIndex = intoArgumentList.get(intoArgumentList.size() - 1).getEndIndex();
        this.intoArgumentList = intoArgumentList;
    }

    public int getBeginIndex() {
        return beginIndex;
    }

    public int getEndIndex() {
        return endIndex;
    }

    public boolean isSql() {
        return sql;
    }

    public DescriptorName getDescriptorName() {
        return descriptorName;
    }

    public boolean isIntoArgumentListEmpty() {
        return intoArgumentList == null || intoArgumentList.isEmpty();
    }

    public int intoArgumentListSize() {
        if (intoArgumentList == null) {
            return 0;
        }
        return intoArgumentList.size();
    }

    public TargetSpecification getIntoArgument(int index) {
        return intoArgumentList.get(index);
    }

}
